package com.sdlg.controller;

import com.sdlg.service.ManagerSettingService;
import com.sdlg.util.POIUtils;
import com.sdlg.util.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/managersetting")
public class ManagerSettingController {
    @Resource
    private ManagerSettingService managerSettingService;

    @RequestMapping("/getOrdersettingInfo")
    public Result getOrdersettingInfo(String date){
        Result result=managerSettingService.getOrdersettingInfo(date);
        return result;
    }
    @RequestMapping("/uploadTempleate")
    public Result uploadTempleate(MultipartFile excelFile){
        try{
            //读取文件信息
            List<String[]> lists = POIUtils.readExcel(excelFile);
            Result result=managerSettingService.saveOrdersettingInfo(lists);
            return result;
        }catch (Exception ex){
            ex.printStackTrace();
        }
        return new Result(false,"保存失败");
    }
    //单独设置某个日期的预约人数
    @RequestMapping("/updateOrdersettingInfo")
    public Result updateOrdersettingInfo(String date,Integer lryId){
        Result result=managerSettingService.updateOrdersettingInfo(date,lryId);
        return result;
    }
}
